package com.dogantekin.allseeingeye.util;

import android.graphics.Bitmap;
import android.location.Location;

public class LocationItem {

	private String   name;
	private String   url;
	private String   phone;
	private double   latitude;
	private double   longitude;
	private double   angleBetween;
	private boolean  left;
	private double   distance;
	private boolean  selected;
	private boolean  visible;
	private float    screenX;
	private float    screenY;
	private Bitmap	 image;
	
	public LocationItem(String name, String url, String phone, double latitude, double longitude) {
		this.name      = name;
		this.url       = url;
		this.phone     = phone;
		this.latitude  = latitude;
		this.longitude = longitude;
	}
	
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getUrl() {
		return url;
	}
	public void setUrl(String url) {
		this.url = url;
	}
	public String getPhone() {
		return phone;
	}
	public void setPhone(String phone) {
		this.phone = phone;
	}
	public double getLatitude() {
		return latitude;
	}
	public void setLatitude(double latitude) {
		this.latitude = latitude;
	}
	public double getLongitude() {
		return longitude;
	}
	public void setLongitude(double longitude) {
		this.longitude = longitude;
	}
	public Bitmap getImage() {
		return image;
	}
	public void setImage(Bitmap image) {
		this.image = image;
	}
	public double getAngleBetween() {
		return angleBetween;
	}
	public void setAngleBetween(double angleBetween) {
		this.angleBetween = angleBetween;
	}
	public boolean isLeft() {
		return left;
	}
	public void setLeft(boolean left) {
		this.left = left;
	}		
	public double getDistance() {
		return distance;
	}
	public void setDistance(double distance) {
		this.distance = distance;
	}
	public boolean isSelected() {
		return selected;
	}
	public void setSelected(boolean selected) {
		this.selected = selected;
	}
	public boolean isVisible() {
		return visible;
	}
	public void setVisible(boolean visible) {
		this.visible = visible;
	}
	public float getScreenX() {
		return screenX;
	}
	public void setScreenX(float screenX) {
		this.screenX = screenX;
	}
	public float getScreenY() {
		return screenY;
	}
	public void setScreenY(float screenY) {
		this.screenY = screenY;
	}
	
	public double calculateDistance(Location location2) {
		double deltaLng = longitude - location2.getLongitude();
		double deltaLat = latitude - location2.getLatitude();
		double temp 	= Math.pow(Math.sin((deltaLat * Math.PI / 180) / 2), 2)
						+ Math.cos(location2.getLatitude() * Math.PI / 180)
						* Math.cos(latitude * Math.PI / 180)
						* Math.pow(Math.sin((deltaLng * Math.PI / 180) / 2), 2);
		double direct   = 2 * Math.atan2(Math.sqrt(temp), Math.sqrt(1 - temp));
		double distance = 6378140 * direct;
		return distance;
	}	
	
}